package com.lysj.order.order.controller;

import com.lysj.admin.utils.constant.CommonConstant;
import com.lysj.admin.utils.spring.foundation.base.BaseController;
import com.lysj.admin.utils.spring.foundation.pagination.PageVo;
import com.lysj.admin.utils.web.Resp;
import com.lysj.order.order.domain.OrderItem;
import com.lysj.order.order.service.OrderItemService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author Created by drj on 2019-03-13 10:43:06
 * @description 订单详情控制层
 */
@Slf4j
@RestController
@RequestMapping("/order/order_item")
public class OrderItemController extends BaseController<OrderItem> {

    @Resource
    private OrderItemService orderItemService;

    @Override
    public OrderItemService getService() {
        return orderItemService;
    }

    /*
     * @author drj
     * @date 2019-03-28 17:11
     * @Description :工作台查看点餐进度
     */
    @GetMapping("/schedule_list")
    public Resp scheduleList(String orderId, Integer status, PageVo pageVo) {
        return new Resp().success(orderItemService.scheduleList(orderId, status, pageVo));
    }

    /*
     * @author drj
     * @date 2019-04-01 11:34
     * @Description :后台订单查看详情
     */
    @GetMapping("/detail")
    public Resp detail(String orderId) {
        return new Resp().success(orderItemService.getRepository().findByOrderIdAndDelFlag(orderId, CommonConstant.NORMAL_FLAG));
    }


    /*
     * @author drj
     * @date 2019-04-15 10:29
     * @Description:工作台赠菜或退菜的接口
     */
    @PostMapping("/gift_or_cancle")
    public Resp giftOrCancle(String orderItemId, Integer status) {
        return new Resp().success(orderItemService.giftOrCancle(orderItemId, status));
    }

}
